#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>

using namespace std;

struct TreeNode {
    int key;
    int color;
    vector<TreeNode *> children;
};

void countColor(TreeNode *root, unordered_map<int, int> &count) {
    if (!root) {
        return;
    }
    count[root->color]++;
    for (TreeNode *node: root->children) {
        countColor(node, count);
    }
}

int main() {
    int n;
    cin >> n;
    // 建树
    vector<TreeNode *> tree(n);
    for (int i = 0; i < n; ++i) {
        auto *node = new TreeNode();
        node->key = i + 1;
        tree[i] = node;
    }

    int p, c;
    for (int i = 0; i < n - 1; ++i) {
        cin >> p >> c;
        TreeNode *node = tree[p - 1];
        TreeNode *child = tree[c - 1];
        node->children.push_back(child);
    }
    int color;
    for (int i = 0; i < n; ++i) {
        cin >> color;
        TreeNode *node = tree[i];
        node->color = color;
    }
    int q;
    cin >> q;
    int query;
    for (int i = 0; i < q; ++i) {
        cin >> query;
        TreeNode *node = tree[query - 1];
        unordered_map<int, int> count;
        countColor(node, count);
        int maxColor = 0, maxW = 0;
        for (const auto &item : count) {
            if (maxW < item.second) {
                maxW = item.second;
                maxColor = item.first;
            } else if (maxW == item.second) {
                maxColor = min(maxColor, item.first);
            }
        }
        cout << maxColor << endl;
    }


}
